<template>
    <div class="payment">
        <el-form label-width="100px">
            <el-form-item label="输入金额:">
                <el-input style="width:300px;" type="number" v-model="number" />
            </el-form-item>
            <el-form-item label>
                <el-button type="primary" @click="submit">立即提现</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { viewBanks, addBanks, outSale } from "../../api/api";
import qs from "qs";

export default {
    data() {
        return {
            number: "",
            bankMsg: []
        };
    },
    created() {
        this.getBank();
    },
    methods: {
        submit() {
            if (this.number <= 0 || this.number == "") {
                this.$message.error("请输入正确数值");
                return false;
            }
            var user = JSON.parse(sessionStorage.getItem("user"));
            var params = {
                amount: this.number,
                token: user.token,
                bankId: this.bankMsg.id
            };
            outSale(qs.stringify(params)).then(res => {
                console.log(res.data);
                if (res.data.code == 200) {
                    this.$message({
                        message: "提现成功！",
                        type: "success"
                    });
                } else {
                    this.$message.error(res.data.msg);
                }
            });
            console.log(params, 666);
        },
        getBank() {
            var user = JSON.parse(sessionStorage.getItem("user"));
            var params = {
                token: user.token
            };
            viewBanks(params).then(res => {
                if (res.data.code == 200) {
                    console.log(res.data.data,6666)
                    this.bankMsg = res.data.data;
                }
            });
        },
        
    }
};
</script>
<style lang="scss" scoped>
.payment {
    padding: 50px 5%;
    box-sizing: border-box;
}
.size {
    background: #409eff;
    color: #f2f2f2;
}
</style>
